<template>
  <div class="clearfix selector">
<!--    品牌-->
    <div class="type-wrap logo">
      <div class="fl key brand">品牌</div>
      <div class="value logos">
        <ul class="logo-list">
          <li
              v-for="t in trademarkList"
              :key="t.tmId"
              @click="selectBrand(t)"
          >{{ t.tmName }}</li>
        </ul>
      </div>
      <div class="ext">
        <a href="javascript:void(0);" class="sui-btn">多选</a>
        <a href="javascript:void(0);">更多</a>
      </div>
    </div>

<!--    参数-->
    <div class="type-wrap"
         v-for="a in attrsList"
         :key="a.attrId"
         @click="clickAttrs"
    >
      <div class="fl key">{{ a.attrName }}</div>
      <div class="fl value">
        <ul class="type-list">
          <li
              v-for="(avl,index) in a.attrValueList"
              :key="index"
          >
            <a
                :data-attrId="a.attrId"
                :data-attrkey="a.attrName"
                :data-attrval="avl"
            >{{ avl }}</a>
          </li>
        </ul>
      </div>
      <div class="fl ext"></div>
    </div>
  </div>
</template>

<script>
import {mapGetters} from 'vuex'

export default {
  name: "Details",
  computed:{
    ...mapGetters('search',['attrsList','trademarkList'])
  },
  methods:{
    // 点击品牌，将数据处理一下，发送给bread
    selectBrand(val) {
      let res = `${val.tmId}:${val.tmName}`
      this.$bus.$emit('selectBrand',res)
    },
    // 通过事件委派，将点击的参数的id，属性名，属性值通过数组形式传给bread
    clickAttrs(e) {
      let element = e.target
      let {attrid, attrkey, attrval} = element.dataset
      if (attrval) {
        let res =`${attrid}:${attrval}:${attrkey}`
        this.$bus.$emit('selectAttr',res)
      }
    }

  }
}
</script>

<style scoped lang="less">
.selector{
  border: 1px solid #ddd;
  margin-bottom: 5px;
  overflow: hidden;
  .logo{
    border-top: 0;
    margin: 0;
    position: relative;
    overflow: hidden;
    .key{
      padding-bottom: 87px!important;
    }
  }
  .type-wrap{
    margin: 0;
    position: relative;
    border-top: 1px solid #ddd;
    overflow:hidden;
    .key{
      width: 100px;
      background: #f1f1f1;
      line-height: 26px;
      text-align: right;
      padding: 10px 10px 0 15px;
      float:left;
    }
    .value{
      overflow: hidden;
      padding: 10px 0 0 15px;
      color: #333;
      margin-left: 5px;
      padding-right: 90px;
      .logo-list{
        margin-left: 40px;
        li{
          float: left;
          border: 1px solid #e4e4e4;
          margin: -1px -1px 0 0;
          width: 105px;
          height: 52px;
          text-align: center;
          line-height: 52px;
          overflow: hidden;
          text-overflow: ellipsis;
          white-space: nowrap;
          font-weight: 700;
          color: #e1251b;
          font-style: italic;
          font-size: 14px;
          cursor: pointer;
          img{
            max-width: 100%;
            vertical-align: middle;
          }
        }
      }
      .type-list{
        li{
          float: left;
          display: block;
          margin-right: 30px;
          line-height: 26px;
          cursor: pointer;
          a{
            text-decoration: none;
            color: #666;
          }
        }
      }
    }
    .ext{
      position: absolute;
      top: 10px;
      right: 10px;
      .sui-btn{
        display: inline-block;
        padding: 2px 14px;
        box-sizing: border-box;
        margin-bottom: 0;
        font-size: 12px;
        line-height: 18px;
        text-align: center;
        vertical-align: middle;
        cursor: pointer;
        padding: 0 10px;
        background: #fff;
        border: 1px solid #d5d5d5;
      }
      a{
        color: #666;
      }
    }
  }
}
</style>
